// pages/agent/orders.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    list:[],
    nav:0,
    pageIndex: 1,
    loadding: false,
    pullUpOn: true,
  },
  onLoad: function(e) {
    this.setData({
      nav:parseInt(e.s  || 0)
    })
    if(this.data.nav==2){
      wx.setNavigationBarTitle({
        title:"待入账订单"
      })
    }
    this.load();
  },
  onReachBottom() {
    this.setData({
      loadding:true,
      pullUpOn:true
    })
    this.load();
  },
  async load(){
    let res=await wx.util.post("agent/orderlist",{page:this.data.pageIndex,s:this.data.nav},this.data.pageIndex>1);
    this.setData({
      pageIndex:this.data.pageIndex++,
      currentTab:this.data.currentTab,
      list:this.data.list.concat(res.data.data),
      loadding:false,
      pullUpOn:false
    })
  },
  detail: function(e) {
    let id=e.currentTarget.dataset.id;
    wx.navigateTo({
      url: '/pages/productDetail/productDetail?id='+id
    })
  },
})